package com.example.main.adapter;

import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;


import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.main.R;
import com.example.main.bean.TravelsBean;

import java.util.List;

public class TravelsAdapter extends BaseQuickAdapter<TravelsBean, BaseViewHolder> {

    public TravelsAdapter(List<TravelsBean> data) {
        super(R.layout.item_travels_view, data);
    }

    @Override
    protected void convert(BaseViewHolder viewHolder, TravelsBean travelsBean) {
        viewHolder.setText(R.id.item_travels_title, travelsBean.getTravels_title());

        RelativeLayout layout = viewHolder.getView(R.id.item_travels_layout);


        switch (viewHolder.getAdapterPosition() % 2) {
            case 0:
                ViewGroup.LayoutParams coverIvParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 700);
                layout.setLayoutParams(coverIvParams);
                break;
            case 1:
                ViewGroup.LayoutParams coverIvParams2 = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 900);
                layout.setLayoutParams(coverIvParams2);
                break;
        }
        ImageView coverIv = viewHolder.getView(R.id.item_travels_cover);
        Glide.with(mContext)
                .load(travelsBean.getTravels_img())
                .into(coverIv);
    }
}
